package m.fun.model;

import m.base.model.UserInfo;
import m.common.model.*;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import m.store.model.GoodsStockRecord;
import m.store.model.StoreGoods;

import java.util.List;
import java.util.stream.Collectors;

@TableMeta(name = "tf_ask_detail", description = "询价明细")
public class AskDetail extends Model implements MigrationModel {
    @Override
    public List<String> migrationOidList(String storeOid) throws Exception {
        return ModelQueryList.getModelList(this.getClass(),new String[]{"oid"},null,
                        QueryCondition.eq("ask.user.store.oid",storeOid))
                .stream().map(Model::getOid).collect(Collectors.toList());
    }
    @LinkTableMeta(name="ask_oid",table= AskInfo.class,description="询价信息")
    private AskInfo ask;
    @LinkTableMeta(name="goods_oid",table= StoreGoods.class,description="商品")
    private StoreGoods goods;
    @FieldMeta(name="title",type= FieldType.STRING,length=200,description="展示名称")
    private String title;
    @FieldMeta(name="price_txt",type= FieldType.STRING,length=20,description="展示价格")
    private String priceTxt;
    @FieldMeta(name="num",type= FieldType.INT,description="数量")
    private Integer num;

    @LinkTableMeta(name="record_oid",table= GoodsStockRecord.class,description="库存记录")
    private GoodsStockRecord record;

    public GoodsStockRecord getRecord() {
        return record;
    }

    public void setRecord(GoodsStockRecord record) {
        this.record = record;
    }

    public AskInfo getAsk() {
        return ask;
    }

    public void setAsk(AskInfo ask) {
        this.ask = ask;
    }

    public StoreGoods getGoods() {
        return goods;
    }

    public void setGoods(StoreGoods goods) {
        this.goods = goods;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getPriceTxt() {
        return priceTxt;
    }

    public void setPriceTxt(String priceTxt) {
        this.priceTxt = priceTxt;
    }

    public Integer getNum() {
        return num;
    }

    public void setNum(Integer num) {
        this.num = num;
    }
}
